$(function() {
    $('.comm-slide-nav').load('./slidenav.html');
    $('.index-htopr').click(function() {
        $('.comm-cover').show();
        $('.comm-slide-nav').css('right', '0');

    });
    $('.comm-cover').click(function() {
        $('.comm-slide-nav').css('right', '-70%');
        $('.comm-cover').hide();
    });

    //禁止遮罩滑动
    $('.comm-cover,.cover-upload').on('touchmove', function(event) {
        event.preventDefault();
    });

    $('.uindex-func-3 a').click(function() {
        $('.uedit-box').hide();
        $(this).next().show();
    })


    //裁剪

    var pc = new PhotoClip('#clipArea', {
        size: 260,
        outputSize: 600,
        //adaptive: ['70%', ''],
        file: '#file',
        ok: '#clipBtn',
        loadStart: function() {
            $('.cover-upload').show();
            $('.cover-prompt').html('正在获取图片...').show();
        },
        loadComplete: function() {
            $('.cover-prompt').hide();
            $('.upload-box').show();
        },
        done: function(dataURL) {
            $('.cover-prompt').html('正在保存图片...').show();
            //保存
            $('.uedit-img').html('<img src="' + dataURL + '">');
            clipSuccess();
            //console.log(dataURL);
        },
        fail: function(msg) {
            alert(msg);
        }
    });

    $('#clipCancel').click(function() {
        clipSuccess();
    });

    function clipSuccess() {
        $('.cover-upload,.upload-box,.cover-prompt').hide();
        pc.clear();
        $('.uedit-box').eq(0).hide();
    }
});